<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        // (function sayHi(){
        //     console.log("大家好，我是渣渣辉");
            
        // })()


        function sayHi(){
            console.log("大家好，我是渣渣辉");
        }
        //只要是函数，加括号就能执行
        sayHi()


        //带参数的函数
        function sum( numa,  numb,numc ,...numother ){
            let all = 0;
            //接收到 所有的参数
            console.log("arguments",arguments);

            //numother剩余参数以数组的形式定义
            console.log("numother",numother);
            
            all += numa + numb+numc;
            // console.log("三个数加和"+(numa + numb+numc)); 
            for (let i = 0; i < numother.length; i++) {
                all +=  numother[i];
                
            }
            
            console.log("多个数累加和"+all); 
            return all

        }
        
        //易学难精
       let calcCum =  sum(100,200,300,400,500,600,700)
       console.log("方法的返回值"+calcCum); 



        
      //匿名函数
    //   setInterval(调用，间隔)
    // function invokeFun(){
    //     console.log("now: "+new Date().getTime());
        
    // }
    // setInterval(invokeFun,1000)




    //升级1 
    // setInterval( function invokeFun(){
    //     console.log("now: "+new Date().getTime());
        
    // },1000)

    //升级2 
    // setInterval( function(){
    //     console.log("now: "+new Date().getTime());
    // },1000)

    // let sai= function(){
    //     console.log("now: "+new Date().getTime());
    // };
    //  setInterval( sai,1000)

    //升级3 ES6 新的写法
    setInterval( ()=>{
        console.log("now: "+new Date().getTime());
    },1000)



        


    </script>
</body>
</html>